/*
 * <p>Copyright® 2009-2022 东软 IT 实训中心版权所有。</p>
 */

package com.max.back.doctor.api;

import com.max.back.common.http.ResponseResult;
import com.max.back.doctor.form.RegistrationForm;
import com.max.back.doctor.form.groups.InsertByRegistrationId;
import com.max.back.doctor.service.PatientHistoryService;
import com.max.back.entity.PatientHistory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 辛凤文 forward.seen@foxmail.com
 * @version 1.0
 * @description <p>
 * <code>PatientHistoryApi</code>
 *
 * </p>
 * @time 2022/7/19 14:31
 * @see
 */
@CrossOrigin
@RestController
@RequestMapping("/patientHistory")
public class PatientHistoryApi {
    @Autowired
    private PatientHistoryService patientHistoryService;

    @GetMapping("/queryAll")
    public List<PatientHistory> queryAllPatientHistory() {
        return patientHistoryService.queryAll();
    }

    @PostMapping("/saveOrUpdateOnePatientHistory")
    public ResponseResult<String> saveOrUpdateOnePatientHistory(@RequestBody @Validated({InsertByRegistrationId.class}) RegistrationForm form) {
        String result = patientHistoryService.createOneAndReturnID(form.getRegistrationId());
        return ResponseResult.getSuccessResult(result);
    }
}